﻿#include "CBasicBattery.h"

CBasicBattery::CBasicBattery(QWidget *parent)
	: QWidget{ parent }
{
	getSize();
}

CBasicBattery::~CBasicBattery()
{

}

void CBasicBattery::getSize()
{
	this->m_width = width();
	this->m_height = height();
}

void CBasicBattery::paintEvent(QPaintEvent *event)
{

}

void CBasicBattery::resizeEvent(QResizeEvent *event)
{
	getSize();
	update();
}

// 设置电量百分比
void CBasicBattery::setLevel(int level) 
{
	m_level = level;
	this->update();
}

// 获取电量百分比
int CBasicBattery::level() const 
{
	return m_level;
}

// 设置电池状态
void CBasicBattery::setStatus(BatteryStatus status)
{
	m_status = status;
	this->update();
}

// 获取电池状态
CBasicBattery::BatteryStatus CBasicBattery::status() const
{
	return m_status;
}

// 设置电池边框颜色
void CBasicBattery::setBorderColor(const QColor &color)
{
	m_border = color;
	this->update();
}

// 获取电池边框颜色
QColor CBasicBattery::borderColor() const 
{
	return m_border;
}

// 设置电池内部填充颜色
void CBasicBattery::setPaddingColor(const QColor &color)
{
	m_padding = color;
	this->update();
}

// 获取电池内部填充颜色
QColor CBasicBattery::paddingColor() const
{
	return m_padding;
}

// 设置充电指示器颜色
void CBasicBattery::setChargeColor(const QColor &color)
{
	m_charge = color;
	this->update();
}

// 获取充电指示器颜色
QColor CBasicBattery::chargeColor() const 
{
	return m_charge;
}

// 设置低电量警告颜色
void CBasicBattery::setLowBatteryColor(const QColor &color) 
{
	m_nobattery = color;
	this->update();
}

// 获取低电量警告颜色
QColor CBasicBattery::lowBatteryColor() const 
{
	return m_nobattery;
}

// 设置绘制偏移量
void CBasicBattery::setOffset(const QPoint &offset) 
{
	m_offset = offset;
	this->update();
}

// 获取绘制偏移量
QPoint CBasicBattery::offset() const 
{
	return m_offset;
}

void CBasicBattery::setRound(bool round)
{
	m_round = round;
	this->update();
}

bool CBasicBattery::isRound() const
{
	return m_round;
}

void CBasicBattery::setRoundPresent(int roundPresent)
{
	m_roundPresent = roundPresent;
	this->update();
}

int CBasicBattery::roundPresent() const
{
	return m_roundPresent;
}


